How to return a string array from an enum in C#?
So I have a enum and I want to pass it to a ComboBox, so I need it to be an array of strings.
Well, this was much more simple than I thought:
public static string[] EnumToStringArray(Type inType) { return Enum.GetNames(typeof(inType)); }
I found a few sites that were taking some much more complex routes, maybe they didn’t know about this feature.
I unable to find the method Enum.GetNames. I can see only GetName method. It returns only string instead of String[]. Do you have any inputs for me ?
I have both functions. According to Microsoft it exists in all versions.
http://msdn.microsoft.com/en-us/library/system.enum.getnames.aspx